<template>
	<section>
		<el-row class="app-container"> 
		<!--编辑界面 ImGroup 群组定义--> 
			<el-form :model="editForm"  label-width="120px" :rules="editFormRules" ref="editForm">
				<el-form-item label="群组主键" prop="id">
					<el-input v-model="editForm.id" placeholder="群组主键"></el-input>
				</el-form-item> 
				<el-form-item label="组名" prop="groupName">
					<el-input v-model="editForm.groupName" placeholder="组名"></el-input>
				</el-form-item> 
				<el-form-item label="组类别" prop="categoryId">
					<el-input v-model="editForm.categoryId" placeholder="组类别"></el-input>
				</el-form-item> 
				<el-form-item label="创建人编号" prop="cuserid">
					<el-input v-model="editForm.cuserid" placeholder="创建人编号"></el-input>
				</el-form-item> 
				<el-form-item label="创建人姓名" prop="cusername">
					<el-input v-model="editForm.cusername" placeholder="创建人姓名"></el-input>
				</el-form-item> 
				<el-form-item label="创建日期" prop="cdate">
					<el-date-picker type="date" placeholder="选择日期" v-model="editForm.cdate"  value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd"></el-date-picker>
				</el-form-item> 
				<el-form-item label="业务状态0已提出1咨询中2已结束" prop="bizStatus">
					<el-input v-model="editForm.bizStatus" placeholder="业务状态0已提出1咨询中2已结束"></el-input>
				</el-form-item> 
				<el-form-item label="群状态0初始1有效2已解散3全体禁言" prop="gstatus">
					<el-input v-model="editForm.gstatus" placeholder="群状态0初始1有效2已解散3全体禁言"></el-input>
				</el-form-item> 
				<el-form-item label="响应状态：I正在响应，S退出响应，O超时未响应，F结束响应" prop="resStatus">
					<el-input v-model="editForm.resStatus" placeholder="响应状态：I正在响应，S退出响应，O超时未响应，F结束响应"></el-input>
				</el-form-item> 
				<el-form-item label="门店编号" prop="locationId">
					<el-input v-model="editForm.locationId" placeholder="门店编号"></el-input>
				</el-form-item> 
				<el-form-item label="商户编号" prop="shopId">
					<el-input v-model="editForm.shopId" placeholder="商户编号"></el-input>
				</el-form-item> 
				<el-form-item label="归属机构号" prop="branchId">
					<el-input v-model="editForm.branchId" placeholder="归属机构号"></el-input>
				</el-form-item> 
				<el-form-item label="在线人数" prop="onlineUsers">
					<el-input v-model="editForm.onlineUsers" placeholder="在线人数"></el-input>
				</el-form-item> 
				<el-form-item label="归属部门" prop="deptid">
					<el-input v-model="editForm.deptid" placeholder="归属部门"></el-input>
				</el-form-item> 
				<el-form-item label="是否允许加入0不允许1允许" prop="allowJoin">
					<el-input v-model="editForm.allowJoin" placeholder="是否允许加入0不允许1允许"></el-input>
				</el-form-item> 
				<el-form-item label="是否需要审核0不需要1需要" prop="needAudit">
					<el-input v-model="editForm.needAudit" placeholder="是否需要审核0不需要1需要"></el-input>
				</el-form-item> 
				<el-form-item label="群头像地址" prop="headimgurl">
					<el-input v-model="editForm.headimgurl" placeholder="群头像地址"></el-input>
				</el-form-item> 
				<el-form-item label="下次允许发言时间" prop="allowSpeechTime">
					<el-date-picker type="date" placeholder="选择日期" v-model="editForm.allowSpeechTime"  value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd"></el-date-picker>
				</el-form-item> 
				<el-form-item label="是否为私聊群0否1是两人人对话有第三人加入自动升级为普通群" prop="isPrichat">
					<el-input v-model="editForm.isPrichat" placeholder="是否为私聊群0否1是两人人对话有第三人加入自动升级为普通群"></el-input>
				</el-form-item> 
				<el-form-item> 
					<el-col :span="24" :offset="8"> 
						<el-button @click.native="handleCancel">取消</el-button>  
						<el-button v-loading="load.edit" type="primary" @click.native="editSubmit" :disabled="load.edit==true">提交</el-button>  
					</el-col> 
				</el-form-item> 
			</el-form>
		</el-row>
	</section>
</template>

<script>
	import util from '@/common/js/util';//全局公共库
	//import { listOption } from '@/api/mdp/meta/itemOption';//下拉框数据查询
	import { editImGroup } from '@/api/mdp/im/group/imGroup';
	import { mapGetters } from 'vuex'
	
	export default { 
		computed: {
		    ...mapGetters([
		      'userInfo'
		    ])
		},
		props:['imGroup','visible'],
		watch: {
	      'imGroup':function( imGroup ) {
	        this.editForm = imGroup;
	      },
	      'visible':function(visible) { 
	      	if(visible==true){
	      		//从新打开页面时某些数据需要重新加载，可以在这里添加
	      	}
	      } 
	    },
		data() {
			return {
				options:{},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]} 
				load:{ list: false, edit: false, del: false, add: false },//查询中...
				editFormRules: {
					id: [
						//{ required: true, message: '群组主键不能为空', trigger: 'blur' }
					]
				},
				//编辑界面数据  ImGroup 群组定义
				editForm: {
					id:'',groupName:'',categoryId:'',cuserid:'',cusername:'',cdate:'',bizStatus:'',gstatus:'',resStatus:'',locationId:'',shopId:'',branchId:'',onlineUsers:'',deptid:'',allowJoin:'',needAudit:'',headimgurl:'',allowSpeechTime:'',isPrichat:''
				}
				/**begin 在下面加自定义属性,记得补上面的一个逗号**/
				
				/**end 在上面加自定义属性**/
			}//end return
		},//end data
		methods: {
			// 取消按钮点击 父组件监听@cancel="editFormVisible=false" 监听
			handleCancel:function(){
				this.$refs['editForm'].resetFields();
				this.$emit('cancel');
			},
			//编辑提交ImGroup 群组定义父组件监听@submit="afterEditSubmit"
			editSubmit: function () {
				this.$refs.editForm.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => { 
							this.load.edit=true
							let params = Object.assign({}, this.editForm); 
							editImGroup(params).then((res) => {
								this.load.edit=false
								var tips=res.data.tips;
								if(tips.isOk){
									this.$refs['editForm'].resetFields();
									this.$emit('submit');//  @submit="afterEditSubmit"
								}
								this.$message({ message: tips.msg, type: tips.isOk?'success':'error' }); 
							}).catch( err =>this.load.edit=false);
						});
					}
				});
			}
			/**begin 在下面加自定义方法,记得补上面的一个逗号**/
				
			/**end 在上面加自定义方法**/
		},//end method
		components: {  
		    //在下面添加其它组件 'im-group-edit':ImGroupEdit
		},
		mounted() {
			this.editForm=Object.assign(this.editForm, this.imGroup);  
		}
	}

</script>

<style scoped>

</style>